package com.lei.huawei;

import java.util.Scanner;

public class JiSuanZiFuJuLi {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String a = scanner.nextLine();
            String b = scanner.nextLine();
            int [][]dp = new int[a.length()+1][b.length()+1];
            for (int i = 1; i <= a.length() ; i++) {
                dp[i][0] = i;

            }
            for (int j = 1; j <= b.length() ; j++) {
                dp[0][j] = j;

            }
            for (int i = 1; i <=a.length() ; i++) {
                for (int j = 1; j <= b.length() ; j++) {
                    if(a.charAt(i-1) == b.charAt(j-1)){
                        dp[i][j] = dp[i-1][j-1];
                    }else {
                        dp[i][j] = Math.min(dp[i-1][j-1]+1,Math.min(dp[i][j-1]+1,dp[i-1][j]+1));
                    }

                }

            }
            System.out.println(dp[a.length()][b.length()]);
        }
        scanner.close();
    }
}
